package com.lincoln.entity.user;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.lincoln.entity.base.BaseEntity;
import com.lincoln.entity.role.DbRole;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;

@Data
@Entity(name = "user")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"})//转json忽略参数
public class DbUser extends BaseEntity {
    //用户名
    @Column(name="user_name",columnDefinition = "varchar(200)",length = 200,nullable = false)
    String userName;

    //密码
    @Column(name="password",columnDefinition = "varchar(200)",length = 200,nullable = false)
    String password;

    //等级id
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "roleId", nullable = false)
    @NotFound(action = NotFoundAction.IGNORE)
    DbRole role;

    @Column(name = "enabled", nullable = false)
    private boolean enabled;

    @Column(name = "account_locked", nullable = false)
    private boolean accountNonLocked;

    @Column(name = "account_expired", nullable = false)
    private boolean accountNonExpired;

    @Column(name = "credentials_expired", nullable = false)
    private boolean credentialsNonExpired;
}
